package com.igbeok.i18n.controller;

import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.AbstractMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/i18n")
public class I18nController {

	@Autowired
	private AbstractMessageSource messageSource;

	@RequestMapping("/message")
	@ResponseBody
	public String getMessage(@RequestParam("key") String name, Locale locale) {
		String value = messageSource.getMessage(name, null, locale);
		System.out.println(value);
		return value;
	}
}
